# 导包
import requests


# 创建接口类
class GoodsAPI:

    # 初始化
    def __init__(self):
        self.goods_list_url = "http://e.cn/api/v1/category/all"
        self.goods_list_info_url = "http://e.cn/api/v1/product/by_category?id={}"
        self.goods_info_url = "http://e.cn/api/v1/product/{}"

    # 获取商品分类信息
    def get_goods_list(self):
        return requests.get(url=self.goods_list_url)

    # 获取商品分类下的商品信息
    def get_goods_list_info(self, list_id):
        return requests.get(url=self.goods_list_info_url.format(list_id))

    # 获取商品详情信息
    def get_goods_info(self, goods_id):
        return requests.get(url=self.goods_info_url.format(goods_id))



























































